package au.com.handsunited.model.relationship;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import au.com.handsunited.model.BaseEntity;
import au.com.handsunited.model.MotherOfAllEntities;

/**
 * @author arunda
 *
 */
public class Relationship extends MotherOfAllEntities implements Comparable<Relationship> {

	private BaseEntity owner;
	private BaseEntity relative;
	private Role role;
	private RelationshipStatus status;

	private static Logger logger = LoggerFactory.getLogger(Relationship.class);



	public Relationship() {
		super();
	}

	public Relationship(BaseEntity owner, BaseEntity relative, Role role, RelationshipStatus status) {
		this();
		this.owner = owner;
		this.relative = relative;
		this.role = role;
		this.status = status;
	}


	public BaseEntity getOwner() {
		return owner;
	}

	public BaseEntity getRelative() {
		return relative;
	}

	public Role getRole() {
		return role;
	}

	public void setOwner(BaseEntity owner) {
		this.owner = owner;
	}

	public void setRelative(BaseEntity relative) {
		this.relative = relative;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public RelationshipStatus getStatus() {
		return status;
	}

	public void setStatus(RelationshipStatus status) {
		this.status = status;
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(Relationship relationship) {
		return getDateCreated().compareTo(relationship.getDateCreated());
	}

	public void approveRelationship() {
		status = RelationshipStatus.ACTIVE;
	}

	public void rejectRelationship() {
		status = RelationshipStatus.INACTIVE;
	}
}
